(clear)      ; Test exists
(watch activations)
(watch facts)

(defrule test
   (exists (a ?))
   =>)
(reset)
(assert (a 1))
(assert (a 2))
(assert (a 3))
(retract 1)
(retract 3)
(retract 2)
(assert (a 4))
(clear)

(defrule test
   (a ?x)
   (exists (b ?x ?))
   =>)
(reset)
(assert (b 1 1))
(assert (b 1 2))
(assert (a 1))
(assert (a 2))
(retract 1)
(retract 2)
(assert (b 2 2))
(assert (b 1 2))
(assert (b 2 3))
(assert (b 1 3))
(retract 7)
(retract 5)
(retract 3)
(unwatch facts)
(unwatch activations)
(clear)
(defrule foo (a) (exists (a) (a)) =>)
(reset)
(assert (a))
(agenda)
(retract 1)
(agenda)
(clear)
